<?php

set_time_limit(0);
include '../../../common.inc.php';
// 开始处理时间: 03-21:13:30
//exit();
if (!isset($start)) {
	$start =0;
}
var_dump($start);
$end = $start+100;
$db->connect('192.168.1.19', 'root', 'root', 'sohu', 0, 'utf8');
$db->query('set names utf8');
$arr = $db->getAll("select * from undupeddata where id>$start and id<=$end ");
if (!$arr) {
	exit('Handle in:"'.$start. '", Handle Over!');
}
$arrids = array();
$con = array();
foreach($arr as $k => $v) {
	$isDelete = isDelete($v);
	if ($isDelete) {
		$arrids[] = $isDelete;
	}

}
var_dump(count($arrids));

if ($arrids) {
	$sql = "delete from wanche where id in (".implode(',', $arrids).")";
	$db->query($sql);
}
$start = $end;
echo  '<meta http-equiv="refresh" content="1; url='.$_SERVER['PHP_SELF'].'?start='.$start.'" />';



function isDelete($rs) {
	$areas = array();
	$area = __DIR__ . '/sohu_area.php';
	if (!file_exists($area)) {
		$AREA = PCache::read('area.php');
		unset($AREA['3418']);
		unset($AREA['3421']);
		foreach($AREA as $k => $v) {
			$areas[] = str_replace(
				array('市', '省', '自治区','盟', '自治州', '地区', '自治县', '藏族', '傈僳族', '景颇族', '傣族', '苗族', '彝族', '白族', '蒙古族', '区'),
				'',
				$v['areaname']);
		}
		PCache::write('sohu_area.php', $areas);
	} else {
		$areas = PCache::read($area);
	}
	$guoyanmao = array(
		'公司',	'公交',	'预定',	'报价',	'价格',	'优惠',	'团购',	'目前',	'详情',	'咨询',	'来店检查',	'现车',	'北京',	'销售',	'邮箱',
		'电话',	'热线',	'网站',	'网址',	'http',	'WWW',	'火车',	'列车',	'时刻',	'车票',	'票价',	'车站',	'车次',	'机票',	'飞机',	'机场',
		'经理',	'号码',	'路线',	'怎么走','摩托',	'开锁',	'门票',	'旅游',	'邮轮',	'不知道','本店',	'赠送',	'汽车召回网','详询',	'上网',
		'不好说',	'顾问',	'光临',	'易车',	'搜狐',	'详情');
	$dicts = array_merge($areas, $guoyanmao);
	foreach($dicts as $dict) {
		if (strpos($rs['tit'].$rs['content'], $dict)) {
			return $rs['id'];
		}
	}
	return 0;
}